#import "JdunionPlugin.h"
#import <JDSDK/JDKeplerSDK.h>

@implementation JdunionPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
    FlutterMethodChannel* channel = [FlutterMethodChannel
                                     methodChannelWithName:@"jdunion_plugin"
                                     binaryMessenger:[registrar messenger]];
    JdunionPlugin* instance = [[JdunionPlugin alloc] init];
    [registrar addMethodCallDelegate:instance channel:channel];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
    if ([@"getPlatformVersion" isEqualToString:call.method]) {
        result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
    } else if ([@"initJdUnion" isEqualToString:call.method]) {
        NSString *version = call.arguments;
        [[JdunionHelper sharedInstance] initJdUnion:version :result];
    } else if ([@"openJDAppByUrl" isEqualToString:call.method]) {
        NSString *url = call.arguments;
        [[JdunionHelper sharedInstance] openJDAppByUrl:url :result];
    } else if ([@"openJXAppByUrl" isEqualToString:call.method]) {
        NSString *url = call.arguments;
        [[JdunionHelper sharedInstance] openJXAppByUrl:url :result];
    } else {
        result(FlutterMethodNotImplemented);
    }
}

@end
